<template>
  <div class="list-div">
    <el-row>
      <el-form>
        <el-col :span="24">
          <el-col :span="4">
            <el-form-item label="分类" label-width="80px">
              <el-select v-model="search.type" clearable filterable placeholder="请选择分类" style="width: 100%">
                <el-option :label="d.name" :value="d.id" :key="d.id" v-for="(d,ddix) in types"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
              <el-form-item label="标题" label-width="80px">
                <el-input v-model="search.title"></el-input>
              </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="" label-width="30px">
              <el-button class="btnAdd" size="mini"  @click="getData()">搜索</el-button>
              <el-button class="btnAdd" size="mini"  @click="add()">添加</el-button>
            </el-form-item>
          </el-col>
        </el-col>
      </el-form>
    </el-row>
    <el-row>
      <el-table :data="page.records" header-row-class-name="tableheader" height="calc(100vh - 220px)" border  style="width: 100%">
        <el-table-column  prop="name" label="name"> </el-table-column>
        <el-table-column  prop="email" label="email"></el-table-column>
        <el-table-column  prop="lable" label="lable"> </el-table-column>
        <el-table-column  prop="message" label="message"> </el-table-column>
        <el-table-column prop="time" label="提交时间">
          <template slot-scope="scope">
            <span>{{common.timestampToTimeMils(scope.row.createDate)}}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-row>
    <div class="pagination">


      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="page.size"
        layout="total,  prev, pager, next, jumper"
        :total="page.total">
      </el-pagination>

    </div>


  </div>

</template>

<script>
  import ElRow from "element-ui/packages/row/src/row";
  import  ImgUpload from './ImgUpload.vue'

  export default {
    components: {ElRow,ImgUpload},
    name: 'ContactsCustomer',
    data () {
      return {
        search:{
          name:null,
          email:null,
          lable:null,
        },
        page: {},
        pageNo: 1,
      }
    },
    methods: {

      handleCurrentChange(val){
        this.pageNo = val
        this.getData()
      },
      getData(){
        this.$axios.get('/admin/contacts-customer/list', {
          params: {
            name: this.search.name,
            email: this.search.email,
            lable: this.search.lable,
            pageNo: this.pageNo,
          }
        }).then(r => {
          let res = r.data
          if (res.code !== 1) {
            this.$message.error(res.msg)
            return
          }
          this.page = res.data
        })
      },
      init () {
        this.getData()
      }
    },
    mounted: function () {
    },
    created: function () {
      this.init()
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  h1, h2 {
    font-weight: normal;
  }

</style>
